package com.youbug.mall.ware_wms.controller;


import com.youbug.common.vo.QueryVo;
import com.youbug.mall.ware_wms.entity.WmsWareInfo;
import com.youbug.mall.ware_wms.service.IWmsWareInfoService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 仓库信息 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-05-01
 */
@RestController
@RequestMapping("/wmsWareInfo")
public class WmsWareInfoController {
@Autowired
private IWmsWareInfoService wmsWareInfoService;

    @PostMapping("/getWmsWareInfoPage")
    public R<IPage<WmsWareInfo>> getWmsWareInfoPage(@RequestBody QueryVo<WmsWareInfo> queryVo){

        IPage<WmsWareInfo> wmsWareInfos = wmsWareInfoService.getWmsWareInfoPage(queryVo);

        return R.ok(wmsWareInfos);
    }

    @GetMapping("/getWmsWareInfoById/{id}")
    public R<WmsWareInfo> getWmsWareInfoById(@PathVariable Integer id){

        WmsWareInfo wmsWareInfo = wmsWareInfoService.getById(id);

        return R.ok(wmsWareInfo);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody WmsWareInfo wmsWareInfo){

        boolean save = wmsWareInfoService.save(wmsWareInfo);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody WmsWareInfo wmsWareInfo){

        boolean update = wmsWareInfoService.updateById(wmsWareInfo);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = wmsWareInfoService.removeById(id);

        return  R.ok(remove);
    }
}

